import { IWorld } from '../common/world.interface';
import { SpriteAnimationRendererComponent } from '../components/sprite-animation-renderer.component';
import { System } from './system';

export class SpriteAnimationSystem extends System {
  onUpdate(world: IWorld, dt: number) {
    const entities = world.findEntitiesByComponent(SpriteAnimationRendererComponent);
    for (const entity of entities) {
      const animationRendererComponent = world.findComponentByEntity(entity, SpriteAnimationRendererComponent)!;
      if (animationRendererComponent.isComplete) {
        continue;
      }

      animationRendererComponent.update(dt);
    }
  }
}
